package com.hightrast.service.api.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * 业务异常code
 *
 */
public enum ExceptionCodeEnum {

    CHOOSE(1, "选择的"),
    QUERY(2, "所有的")
    ;

    /**
     * 值
     */
    @EnumValue
    private final Integer value;

    /**
     * 描述
     */
    private final String desc;

    ExceptionCodeEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @JsonCreator
    public static ExceptionCodeEnum getItem(int code) {
        for (ExceptionCodeEnum item : values()) {
            if (item.getValue() == code) {
                return item;
            }
        }
        return null;
    }

    public Integer getValue() {
        return value;
    }

    @JsonValue
    public String getDesc() {
        return desc;
    }
}
